#ifndef _core_switch_cases_hpp_
#define _core_switch_cases_hpp_

/** \file cases.hpp
 *  \author Adrian Schweizer
 *  \created  $Mo 11 Feb 08:33:01 pm CET 2008 schwadri@SchwadriLaptop.local$
 *  \modified $Mo 11 Feb 08:34:18 pm CET 2008 schwadri@SchwadriLaptop.local$
 */

#include <boost/mpl/vector_c.hpp>

#include <boost/preprocessor/limits.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/local.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>

#include "case_sequence.hpp"

#ifndef CORE_SWITCH_LIMIT_CASES_C
    #define CORE_SWITCH_LIMIT_CASES_C 10
#endif

#if (CORE_SWITCH_LIMIT_CASES_C > BOOST_PP_LIMIT_REPEAT)
    #error CORE_SWITCH_LIMIT_CASES_C... exceeds Boost.Preprocessor limit
#endif
#if (CORE_SWITCH_LIMIT_CASES_C > BOOST_PP_LIMIT_ITERATION)
    #error CORE_SWITCH_LIMIT_CASES_C... exceeds Boost.Preprocessor limit
#endif

namespace core {

    #define CORE_SWITCH_GENERATE_CASES_C(n)                                         \
    template <typename T, BOOST_PP_ENUM_PARAMS(n,T Key), typename Functor>          \
        case_sequence<boost::mpl::BOOST_PP_CAT(BOOST_PP_CAT(vector,n),_c)<T,          \
                    BOOST_PP_ENUM_PARAMS(n,Key)>,Functor>                           \
        cases_c(const Functor& functor)                                             \
        {                                                                           \
            return case_sequence<boost::mpl::BOOST_PP_CAT(BOOST_PP_CAT(vector,n),_c)< \
                        std::size_t,BOOST_PP_ENUM_PARAMS(n,Key)>,Functor>(functor); \
        }

    template <typename Cases, typename Functor>
        case_sequence<Cases,Functor>  cases(const Functor& functor)
        {
            return case_sequence<Cases,Functor>(functor);
        }

    #define BOOST_PP_LOCAL_MACRO  CORE_SWITCH_GENERATE_CASES_C
    #define BOOST_PP_LOCAL_LIMITS (1, CORE_SWITCH_LIMIT_CASES_C)
    //DO NOT REMOVE WHITESPACE   ^
    #include BOOST_PP_LOCAL_ITERATE()
    #undef CORE_SWITCH_GENERATE_CASES_C

} // namespace core

#endif // _core_switch_cases_hpp_
